import request from "@/utils/request";
// import axios from 'axios'
import { apiVersion } from "@/config";
// import { getDeviceId } from '@/utils/tool'

// 用户信息
export function usersInfo(data) {
	return request({
		url: `/user/${apiVersion}/user/info`,
		method: "get",
		data,
	});
}

// 二次登陆（切换用的）
export function changeOrgAuthToken(data) {
	let params = "";
	for (let i in data) {
		params += `${i}=${data[i]}&`;
	}
	return request({
		url: `/auth/${apiVersion}/oauth/token?${params}`,
		method: "post",
		data,
	});
}
// 验证码
export function verificationCode(data) {
	return request({
		url: `/auth/${apiVersion}/verification/code`,
		method: "get",
		data,
	});
}
// 登录
export function login(data) {
	let params = "";
	for (let i in data) {
		params += `${i}=${data[i]}&`;
	}
	return request({
		url: `/auth/${apiVersion}/oauth/token?${params}`,
		method: "post",
		data,
	});
}
// 撤回token
export function revokeToken(data) {
	return request({
		url: `/auth/${apiVersion}/oauth/revokeToken`,
		method: "get",
		data,
	});
}

// 修改密码
export function password(data) {
	return request({
		url: `/auth/${apiVersion}/oauth/password`,
		method: "put",
		data,
	});
}

// 置换token
export function displaceToken(data) {
	return request({
		url: `/auth/${apiVersion}/oauth/displaceToken?organizationId=` + data.organizationId,
		method: "put",
		data,
	});
}

// htzny登录
export function htznyLogin(data) {
	let params = "";
	for (let i in data) {
		params += `${i}=${data[i]}&`;
	}
	return request({
		url: `/auth/${apiVersion}/oauth/htznytoken?${params}`,
		method: "post",
		data,
	});
}
